package com.lyp.qczp.contoller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lyp.qczp.entity.Roles;
import com.lyp.qczp.service.RolesService;
@RestController
@CrossOrigin(origins = "*")
public class RolesController {
	@Autowired
	private RolesService rolesService;
	@PostMapping("/saveRoles")
	public int saveRoles(Roles roles) {
		return rolesService.save(roles);
	}
	@PostMapping("/deleteRoles")
	public int deleteById(Integer roId) {
		// TODO Auto-generated method stub
		
		return rolesService.deleteById(roId);
	}
	@PostMapping("/findAllRoles")
	public Map<String, Object> findAll(Integer page,Integer rows) {
		PageRequest of = PageRequest.of(page-1, rows);
		return rolesService.findAll(of);
	}
	
}
